package com.djinfo.work.dao.impl;

import com.djinfo.work.common.dao.impl.BaseDaoImpl;
import com.djinfo.work.dao.QsUserDao;
import com.djinfo.work.entity.QsUserEntity;
import org.springframework.stereotype.Repository;

import java.util.List;

/**
 * @date 2017-06-08 10:48:15
 */
@Repository("QsUserDao")
public class QsUserDaolmpl extends BaseDaoImpl implements QsUserDao {

    @Override
    public void saveOrUpdate(QsUserEntity object) {
        if(null==object.getId()){
            super.save(object);
        }else{
            super.update(object);
        }

    }

    @Override
    public List<QsUserEntity> page(String hql, Integer pageNum, Integer pageSize) {


        return (List<QsUserEntity>)super.pageQuery( hql,  pageNum,  pageSize);
    }

    @Override
    public List<QsUserEntity> list(QsUserEntity object) {
        String hql = " from QsUserEntity where 1=1 ";
        return (List<QsUserEntity>)super.getList(hql);
    }

    @Override
    public Integer getAllRowCount(String hql) {
        return super.getUniqueObject(hql).hashCode();
    }

    @Override
    public void delete(QsUserEntity object) {
        super.delete(this.selectOne(object));
    }

    @Override
    public QsUserEntity selectOne(QsUserEntity object) {
        return (QsUserEntity)super.get(QsUserEntity.class,object.getId());
    }

    @Override
    public QsUserEntity getById(String id) {
        return (QsUserEntity)super.getByPrimaryKey(QsUserEntity.class, id);
    }

    @Override
    public void save(QsUserEntity object) {
        super.save(object);
    }
}
